/**
 * 湖南江河机电自动化设备股份有限公司 版权所有
 * Copyright @2016-2020 All Rights Reserved
 */
package com.hnjme.cnec.mdm.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.hnjme.cnec.mdm.ws.StaffResult;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.Alias;
import org.springframework.util.Assert;

/**
 * @author outta
 * @Since 1.0 2018/8/29
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Alias("originStaff")
@ApiModel("员工(过时的)")
public class OriginStaff extends  Staff {

    @ApiModelProperty("原员工代码")
	@JsonIgnoreProperties
	private String originCode;

    @ApiModelProperty("原单位代码")
	@JsonIgnoreProperties
	private String originUnitCode;

    public static Staff convert(StaffResult origin) {

        Assert.notNull(origin, "目标员工不能为空");
        OriginStaff staff = new OriginStaff();
        staff.setCode(origin.getCode());
        staff.setOriginCode(origin.getHrbm());
        staff.setName(origin.getName());
        staff.setUsedName(origin.getUsedname());
        staff.setGender(origin.getSex());
        staff.setIdCardNo(origin.getIdNo());
        staff.setBirthday(origin.getBirthdate());
        staff.setUnitCode(origin.getOwnUnitcode());
        staff.setUnitName(origin.getOwnUnitname());
        staff.setDeptCode(origin.getOwnDeptcode());
        staff.setOriginUnitCode(origin.getHrdeptbm());
        staff.setDeptName(origin.getOwnDeptname());
        staff.setEntryDate(origin.getEntryDate());
        staff.setQuitDate(origin.getQuitDate());
        staff.setEmail(origin.getEmail());
        staff.setTel(origin.getTel());
        staff.setPhone(origin.getPhone());
        staff.setPost(origin.getPostName());
        staff.setPostCode(origin.getGwbm());
        staff.setPostValue(origin.getPostNameValue());
        staff.setCategory(origin.getOwnCategory());
        staff.setCategoryValue(origin.getOwnCategoryValue());
        staff.setPosition(origin.getGwxlmc());
        staff.setPositionCode(origin.getGwxlbm());
        staff.setStatus(true);
        return staff;
    }
}
